package com.ubhave.powertrackernof1;

import android.content.SharedPreferences;
import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;

public class PowerTrackerNetworkLocationListener implements LocationListener {

	SharedPreferences settings;
	
	@Override
	public void onLocationChanged(Location l) {
		
		settings=PreferenceManager.getDefaultSharedPreferences(PowerTrackerApplication.getContext());
        SharedPreferences.Editor editor = settings.edit();
        
        if(settings.getBoolean("GPSset", false)){
        	editor.putBoolean("GPSset", false);
        }
        else{
        	editor.putString("CurrentLat", ""+l.getLatitude());
            editor.putString("CurrentLng", ""+l.getLongitude());
            editor.putString("CurrentLocSensor", "Network");
        }
        
        editor.commit();
		
		Log.i("POWeR Tracker Sensor: ","BASIC LocSense NetData "+l.getLatitude()+" "+l.getLongitude());
		//Toast.makeText(PowerTrackerApplication.getContext(), "POWeR Tracker NetData."+l.getLatitude()+" "+l.getLongitude(), Toast.LENGTH_SHORT).show();
		
		
	}

	@Override
	public void onProviderDisabled(String provider) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onProviderEnabled(String provider) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onStatusChanged(String provider, int status, Bundle extras) {
		// TODO Auto-generated method stub
		
	}
	
	
	
}